﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.OracleClient;
using System.Data.Common;
using System.IO;

namespace CCPSIP
{
    public partial class UnitTest : System.Web.UI.Page
    {
        string[] Major = { "11111", "11111" };
        string[] Minor = { "10006", "10001" };
        string[] Proximity = { "NEAR", "NEAR" };

        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void Button1_Click(object sender, EventArgs e)
        {

            //bool s = iBeaconKit.IsBeaconExist(Major, Minor);
        }

        protected void Button2_Click(object sender, EventArgs e)
        {
            //List<Rule> r = iBeaconKit.GetRuleList(Major, Minor, Proximity);

            //int j = 0;
        }

        protected void Button3_Click(object sender, EventArgs e)
        {
            bool s = iBeaconKit.IsMapExist("資訊中心五樓_2014-10-03-16-00.jpg");
        }

        protected void Button4_Click(object sender, EventArgs e)
        {
            if (!PCKit.IsLogedin("88238"))
                PCKit.InsertLoginData("88238", "1234");
        }

        protected void Button5_Click(object sender, EventArgs e)
        {
            //bool hadUser = IPPbxKitV3.HadUser(SIP_Num);
            Dictionary<string, string> paramDict = null;
            paramDict = IPPbxKitV3.GetUserData("8823888");

            //int i = 0;
        }

        protected void Button6_Click(object sender, EventArgs e)
        {
            //List<OracleKitAddressBook.Company> c = new List<OracleKitAddressBook.Company>();
            //c = OracleKitAddressBook.GetCompanyAndDepartmentList();

            List<string> s = new List<string>();    //company_and_firm_code
            s.Add("11");
            s.Add("22");

            //OracleKitAddressBook.GetDepartmentsByDeptNo(s);
        }

        protected void Button7_Click(object sender, EventArgs e)
        {
            List<string> s = new List<string>();    //company_and_firm_code
            s.Add("11");
            s.Add("22");

            //string department = "MI";

            //OracleKitAddressBook.GetPeopleByDepartment(s, department);
        }

        protected void Button8_Click(object sender, EventArgs e)
        {
            List<OracleAddressBookKit.Person> p = OracleAddressBookKit.GetPersonAll(false, false);
        }

        protected void Button9_Click(object sender, EventArgs e)
        {
            List<OracleAddressBookKit.Person> AbroadPeople = OracleAddressBookKit.GetAbroadPeople();

            //OracleKitAddressBook.GetAbroadPeopleByCompany("長龍化工(深圳)", AbroadPeople);

        }

        protected void Button10_Click(object sender, EventArgs e)
        {
            string SIP_Num = "88238";


            //code start
            OracleConnection connOracle = new OracleConnection("SERVER=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.52.195)(PORT=1521)))(CONNECT_DATA =(SERVER=DEDICATED)(SID=UNIDB)));uid=ISENDER;pwd=aKhJJFA2sWfEsQz0Zm5iwQi9gjiVND");
            OracleCommand cmd = new OracleCommand("SELECT CustomName FROM reg_user WHERE Status='Y' AND SIP_Num=:SIP_Num", connOracle);
            cmd.Parameters.Add(":SIP_Num", OracleType.VarChar).Value = SIP_Num;
            connOracle.Open();

            string ReturnCustomName = Convert.ToString(cmd.ExecuteScalar());
            connOracle.Dispose();

            //return ReturnCustomName;
        }

        protected void Button11_Click(object sender, EventArgs e)
        {
            //int i = 0;
        }

        protected void Button12_Click(object sender, EventArgs e)
        {
            List<OracleAddressBookKit.CompanyAreacodeMapping> s = OracleAddressBookKit.GetCompanyAreaMappingList();
        }

        protected void Button13_Click(object sender, EventArgs e)
        {
            string s = OracleKit.GetDutyCode("23204");
        }

        protected void Button14_Click(object sender, EventArgs e)
        {
            bool b = OracleKitGroup.IsGroupExist("G_PBT_EXCEPTION_MIjjj");
        }

        protected void Button15_Click(object sender, EventArgs e)
        {
            bool s = OracleAddressBookKit.HasAdminRight("23205");
        }

        protected void Button16_Click(object sender, EventArgs e)
        {
            /*
            Guid guid = Guid.NewGuid();
            string file_name = "C:\\InsertSpeedTest_" + DateTime.Now.ToString("yyyy-MM-dd-HH-mm-ss_") + guid + ".sqlite";

            SQLiteConnection.CreateFile(file_name);

            SQLiteConnection m_dbConnection = new SQLiteConnection("Data Source=" + file_name +";Version=3;");
            m_dbConnection.Open();

            string sql = "create table InsertTest (Column1 varchar(20), Column2 varchar(20), Column3 varchar(20))";

            SQLiteCommand command = new SQLiteCommand(sql, m_dbConnection);
            command.ExecuteNonQuery();
            sql = "insert into InsertTest (Column1, Column2, Column3) values ('XXXXXXXX', 'QQQQQQQQQQQQQ', 'GGGGGGGGGGGGGGGG')";
            command = new SQLiteCommand(sql, m_dbConnection);

            DbTransaction trans = m_dbConnection.BeginTransaction();

            for (int i = 0; i < 50000; i++)
            {
                command.ExecuteNonQuery();
            }

            trans.Commit();
            trans.Dispose();
            m_dbConnection.Close();*/

            //File.Delete("C:\\InsertSpeedTest.sqlite");
        }

        protected void Button17_Click(object sender, EventArgs e)
        {
            OracleAddressBookKit.AddressBookInfo a = OracleAddressBookKit.GetAddressBookInfo("LTS2XX");
        }

        protected void Button18_Click(object sender, EventArgs e)
        {

            bool s = OracleDataMaintainKit.CheckPhoneHQ("99999");
        }

        protected void Button19_Click(object sender, EventArgs e)
        {
            OracleDataMaintainKit.PhoneHQ PersonData = new OracleDataMaintainKit.PhoneHQ()
                {
                    Phone_Num = "998",
                    PPS_Code = "99998",
                    Full_Name = "tester",
                    Section_Name = "test section"
                };

            bool s = OracleDataMaintainKit.InsertPhoneHQ(PersonData);
        }

        protected void Button20_Click(object sender, EventArgs e)
        {
            OracleDataMaintainKit.PhoneHQ PersonData = new OracleDataMaintainKit.PhoneHQ()
            {
                Phone_Num = "999",
                PPS_Code = "99999",
                Full_Name = "更新測試",
                Section_Name = "更新測試部門"
            };

            bool s = OracleDataMaintainKit.UpdatePhoneHQ(PersonData);
        }

        protected void Button21_Click(object sender, EventArgs e)
        {
            bool s = OracleDataMaintainKit.DeletePhoneHQ("99999");
        }

        protected void Button22_Click(object sender, EventArgs e)
        {
            //OracleDataMaintainKit.DisableRegUser("23204");
        }

        protected void Button23_Click(object sender, EventArgs e)
        {
            if (IPPbxKitV3.HadUser("1940001"))
                IPPbxKitV3.DeleteUser("1940001");

            bool s = false;
        }

        protected void Button24_Click(object sender, EventArgs e)
        {
            CloudDiskKit.DeleteUserFolder("88238");
        }
    }
}